home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Applications / Conversion / Convert_PICT / Source / UncommentedPSCode / Bitmaps < prev    next >
Text File  |  1994-05-24  |  5KB  |  230 lines

  1. %BEGIN Bitmaps
  2. /lengthByte 1 string def
  3. /runByte 1 string def
  4.  
  5. /unpackbytes 
  6.     /thelength 
  7.         currentfile lengthByte readhexstring pop 
  8.         0 get 
  9.     def 
  10.     thelength 128 lt 
  11.     { 
  12.         /dataString thelength 1 add  string def 
  13.         currentfile dataString readhexstring pop 
  14.     }
  15.     { 
  16.         /runlength 257 thelength sub def 
  17.         /runString runlength  string def
  18.         currentfile runByte readhexstring pop pop 
  19.  
  20.         0 1 runlength 1 sub 
  21.             { runString exch runByte putinterval } 
  22.         for 
  23.         runString 
  24.     } 
  25.     ifelse 
  26. }
  27. def
  28. /bitmap
  29. {
  30.     gsave
  31.         {
  32.             initclip
  33.             regionBounds
  34.             clip
  35.             /numShapes exch def
  36.             numShapes  0 gt
  37.             {
  38.                 numShapes
  39.                 regionPath
  40.                 clip
  41.             }
  42.             if
  43.         }
  44.         if
  45.         /isPacked exch def
  46.         /sourceHeight exch def
  47.         /sourceWidth exch def
  48.         /destHeight exch def
  49.         /destWidth exch def
  50.         /boty exch def
  51.         /botx exch def
  52.         /mode exch def
  53.         /bitDepth exch def        % unused
  54.         /colordata exch def    %  "
  55.         /numcolors exch def    %  "
  56.         /scanString  sourceWidth 8 div ceiling cvi  string def
  57.         botx boty destHeight add translate
  58.         destWidth destHeight scale
  59.         0 setgray
  60.         PSlevel 1 eq
  61.         {
  62.             mode /srcOr eq
  63.             mode /notSrcOr eq
  64.             or 
  65.             {
  66.                 sourceWidth sourceHeight     mode /notSrcOr eq
  67.                 [sourceWidth 0 0  sourceHeight 0 sourceHeight] 
  68.                 isPacked true eq
  69.                     { {unpackbytes} }
  70.                     { {currentfile scanString readhexstring pop} } 
  71.                 ifelse
  72.                 imagemask
  73.             }
  74.             {
  75.                 sourceWidth sourceHeight 1
  76.                 [sourceWidth 0 0  sourceHeight 0 sourceHeight] 
  77.                 isPacked true eq
  78.                     { {unpackbytes} }
  79.                     { {currentfile scanString readhexstring pop} } 
  80.                 ifelse
  81.                 image
  82.             }
  83.             ifelse
  84.             isPacked false eq
  85.                 { 2 { currentfile read pop pop } repeat  }
  86.                 { 4 { currentfile read pop pop } repeat  }
  87.             ifelse
  88.         }
  89.         {
  90.             /DeviceGray  setcolorspace
  91.             /imageParams 7 dict def
  92.             imageParams begin
  93.                 /ImageType            1    def
  94.                 /Width                 sourceWidth  def
  95.                 /Height                sourceHeight  def
  96.                 /BitsPerComponent    1    def
  97.                 /Decode            mode /notSrcOr eq
  98.                                     { [ 1 0 ] }  { [ 0 1 ] } ifelse def
  99.                 /ImageMatrix    [sourceWidth 0 0  sourceHeight
  100.                                     0 sourceHeight]  def
  101.                 /DataSource isPacked true eq
  102.                             { currentfile  /ASCIIHexDecode filter
  103.                                 /RunLengthDecode filter}
  104.                             { currentfile  /ASCIIHexDecode filter}
  105.                             ifelse
  106.                         def
  107.             end
  108.             mode /srcOr eq
  109.             mode /notSrcOr eq
  110.             or 
  111.                 { imageParams imagemask }
  112.                 { imageParams image }
  113.             ifelse
  114.         }
  115.         ifelse
  116.     grestore
  117. }
  118. def
  119. /colorbitmap
  120.     gsave
  121.         {
  122.             initclip
  123.             regionBounds
  124.             clip
  125.             /numShapes exch def
  126.             numShapes  0 gt
  127.             {
  128.                 numShapes
  129.                 regionPath
  130.                 clip
  131.             }
  132.             if
  133.         }
  134.         if
  135.         /isPacked exch def
  136.         /sourceHeight exch def
  137.         /sourceWidth exch def
  138.         /destHeight exch def
  139.         /destWidth exch def
  140.         /boty exch def
  141.         /botx exch def
  142.         /mode exch def
  143.         /sampleDepth  exch def
  144.         /colordata exch def
  145.         /numcolors exch def
  146.         botx boty destHeight add translate
  147.         destWidth destHeight scale
  148.         PSlevel 1 eq
  149.         {
  150.             /scanString  sourceWidth sampleDepth mul 8 div
  151.                     ceiling cvi  string def
  152.             sourceWidth sourceHeight sampleDepth
  153.             [sourceWidth 0 0  sourceHeight 0 sourceHeight] 
  154.             isPacked true eq
  155.                 { {unpackbytes} }
  156.                 { {currentfile scanString readhexstring pop} } 
  157.             ifelse
  158.             image
  159.             isPacked false eq
  160.                 { 2 { currentfile read pop pop } repeat  }
  161.                 { 4 { currentfile read pop pop } repeat  }
  162.             ifelse
  163.         }
  164.         {
  165.             [ /Indexed  /DeviceRGB numcolors colordata] setcolorspace
  166.             /imageParams 7 dict def
  167.             imageParams begin
  168.                 /ImageType        1 def
  169.                 /Width             sourceWidth def
  170.                 /Height            sourceHeight def
  171.                 /BitsPerComponent    sampleDepth def
  172.                 /Decode            [ 0 2 sampleDepth exp 1 sub ] def
  173.                 /ImageMatrix    [sourceWidth 0 0  sourceHeight 0
  174.                                     sourceHeight]  def
  175.                 /DataSource     isPacked true eq
  176.                             { currentfile  /ASCIIHexDecode filter
  177.                                     /RunLengthDecode filter}
  178.                             { currentfile  /ASCIIHexDecode filter}
  179.                             ifelse
  180.                         def
  181.             end
  182.             imageParams image
  183.         }
  184.         ifelse
  185.     grestore
  186. }
  187. def
  188. /24bitBitmap
  189.     gsave
  190.         {
  191.             initclip
  192.             regionBounds
  193.             clip
  194.             /numShapes exch def
  195.             numShapes  0 gt
  196.             {
  197.                 numShapes
  198.                 regionPath
  199.                 clip
  200.             }
  201.             if
  202.         }
  203.         if
  204.         /isPacked exch def
  205.         /sourceHeight exch def
  206.         /sourceWidth exch def
  207.         /destHeight exch def
  208.         /destWidth exch def
  209.         /boty exch def
  210.         /botx exch def
  211.         /mode exch def
  212.         botx boty destHeight add translate
  213.         destWidth destHeight scale
  214.         /scanString  sourceWidth  3 mul  string def
  215.         sourceWidth sourceHeight 8
  216.         [sourceWidth 0 0  sourceHeight 0 sourceHeight] 
  217.         isPacked true eq
  218.             { {unpackbytes} }
  219.             { {currentfile scanString readhexstring pop} } 
  220.         ifelse
  221.         false 3
  222.         colorimage
  223.     grestore
  224. }
  225. def
  226. %END Bitmaps
  227.